def jc(n):
    t = 1
    r = 1
    for i in range(n):
        r *= t
        t += 1 
    return r 

def method(nums):
    # 1 乘上自己的下标，统计每个值出现的次数
    d = {}
    for i in range(len(nums)):
        t = nums[i] * (i + 1)
        if t not in d:
            d[t] = 0
        d[t] += 1

    # 3 组合数计算
    r = 0
    for n in d.values():
        c = jc(n) // 2
        r += c
    return r

def _test():
    nums = [16, 8, 1, 4, 1, 1, 1, 2]
    print(method(nums))

if __name__ == '__main__':
    # nums = [int(x) for x in input().split(' ')]
    # r = method(nums)
    # print(r)

    _test()